added test and refactored Online model