#15: Code optimization and small test fix